-
Couldn't load subscription status.
- Fork 460
⚠️ Add strongly typed EventNotifications #1538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
[skip ci]
[skip ci]
|
(ignore red CI; docker hub is having a problem so all tests are down. Everything besides compat was good before i merged master back into this and trigger the CI run.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple comments/questions but otherwise good to go!
* wip generating push payload events [skip ci] * improve generation [skip ci] * generate related object method * Return a union from parse thin event & add UnknownThinEvent * fix unused import * fix related_object generation and add big test * Some name cleanup * rename thin_event * small fixes * export UnknownEventNotification * fix reason parsing * rename thin_event * fix example & re-export event notifications * move some imports * swap event fetch_related_object to stripe-context * update docstring * update comment Co-authored-by: David Brownman <[email protected]> Co-authored-by: Ramya Rao <[email protected]>
Why?
As part of the Next-Gen Event Handling project, we're adding fully typed classes to represent all the
thin eventsEvent Notifications a user could receive. There are also helper methods that help with the event handling experience.What?
just test-onerecipeTHIN_EVENT_CLASSESfrom_jsonstatic constructor toEventNotificationSee Also
DEVSDK-2662
Changelog
We've overhauled how V2 Events are handled in the SDK! This approach should provide a lot more information at authoring and compile time, leading to more robust integrations. As part of this process, there are a number of changes to be aware of.
EventNotificationclasses to every v2Event. For example, there's now aV1BillingMeterErrorReportTriggeredEventNotificationto match the existingV1BillingMeterErrorReportTriggeredEvent. Each notification class defines afetch_event()method to retrieve its corresponding event. For events with related objects, there's afetch_related_object()method that performs the API call and casts the response to the correct type.StripeClient.parse_thin_eventtoStripeClient.parse_event_notificationand remove theStripe.ThinEventclass.stripe.v2.core.EventNotification(which is the shared base class that all of the more specificstripe.events.*EventNotificationclasses share) instead ofStripe.ThinEvent. When applicable, these event notifications will have therelated_objectproperty and afetch_related_object()function. They also have afetch_()method to retrieve their correspondingstripe.events.*Eventinstance.Stripe.Events.UnknownEventNotificationinstead of a more specific type. It has both therelatedObjectproperty and theFetchRelatedObject()function (but they may be/returnnull)